package com.zys.hotel_management.service.impl;


import com.zys.hotel_management.entity.Customer;
import com.zys.hotel_management.mapper.CustomerMapper;
import com.zys.hotel_management.service.CustomerService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class CustomerServiceImpl implements CustomerService {
    @Resource
    private CustomerMapper customerMapper;

    @Override
    public void register(Customer customer) {
        customerMapper.insert(customer);
    }

    @Override
    public Customer login(String username, String password) {
        Customer customer = customerMapper.findByUsername(username);
        if (customer != null && customer.getPassword().equals(password)) {
            return customer;
        }
        return null;
    }

    @Override
    public Customer getById(Integer customerId) {
        return customerMapper.findById(customerId);
    }

    @Override
    public Customer getByUsername(String username) {
        return customerMapper.findByUsername(username);
    }
}